<?php if(!defined("HDPHP_PATH"))exit;C("SHOW_NOTICE",FALSE);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
        <head>
                <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
                        <title>Document</title>
                        <link rel="stylesheet" href="http://localhost/shopFrame/Application/Admin/View/Public/Css/bootstrap.min.css" />
                        <link rel="stylesheet" href="http://localhost/shopFrame/Application/Admin/View/Public/Css/common.css" />
                        <script type='text/javascript' src='http://localhost/shopFrame/hdphp/Extend/Org/Jquery/jquery-1.8.2.min.js'></script>

                        <script type="text/javascript">
                                $(function() {
                                        var sel = $('select[name="combattrid[]"]');
                                        var len = sel.length;
                                        sel.change(function() {
                                                var param = {
                                                        'gid': <?php echo $_GET['gid'];?>,
                                                        'combattrid': {}
                                                }
                                                for (var i = 0; i < len; i++) {
                                                        if (sel.eq(i).val() == 0) {
                                                                return false;
                                                        }
                                                        param.combattrid[i] = sel.eq(i).val();
                                                }
                                                $.ajax({
                                                        url: 'http://localhost/shopFrame/index.php/Admin' + '&m=Admin&c=GoodsList&a=check',
                                                        type: 'post',
                                                        data: param,
                                                        dataType: 'json',
                                                        success: function(data)
                                                        {
                                                                if (data == 0)
                                                                {
                                                                        $('.warning').html('该货品已存在！');
                                                                        $('input[type=submit]').attr({'disabled': 'disabled'});
                                                                } else {
                                                                        $('.warning').html('');
                                                                        $('input[type=submit]').removeAttr('disabled');
                                                                }
                                                        }
                                                });
                                        })
                                })
                        </script>
                        <style type="text/css">
                                body{
                                        margin-bottom: 100px;
                                }
                                input[type=text]{
                                        margin-bottom: 0px;
                                }
                        </style>
        </head>
        <body>
                <div class="container-fluid">
                        <div class="row-fluid">
                                <div class="span12">

                                        <form action="" method='post'>
                                                <table class='table table-bordered table-hover'>
                                                        <tr>
                                                                <th>货品ID</th>
                                                                <?php if(is_array($standname)){?><?php  foreach($standname as $key=>$v){ ?>
                                                                        <th><?php echo $v['taname'];?></th>
                                                                <?php }}?>
                                                                <th>库存</th>
                                                                <th>货号</th>
                                                                <th>操作</th>
                                                        </tr>

                                                        <?php if(is_array($goodslist)){?><?php  foreach($goodslist as $key=>$v){ ?>


                                                                <tr class="info">
                                                                        <td><?php echo $v['glid'];?></td>
                                                                        <?php if(is_array($v['ganame'])){?><?php  foreach($v['ganame'] as $key=>$s){ ?>
                                                                                <td><?php echo $s;?></td>
                                                                        <?php }}?>                       
                                                                        <td><?php echo $v['stock'];?></td>
                                                                        <td><?php echo $v['number'];?></td>
                                                                        <td>
                                                                                <?php if($v["comb"] == $v["combattrid"]){?>
                                                                                        <a href="javascript:;" class="btn btn-primary btn-disabled" disabled='disabled'><i class="icon-pencil icon-white"></i>默认货号</a>
                                                                                        <?php  }else{ ?>
                                                                                                <a href="<?php echo U('setdefault',array('glid'=>$v['glid'],'gid'=>$_GET['gid']));?>" class="btn btn-success"><i class="icon-pencil icon-white"></i>设为默认</a>
                                                                                <?php }?> 
                                                                                <a href="<?php echo U('edit',array('glid'=>$v['glid'],'gid'=>$_GET['gid']));?>" class="btn btn-warning"><i class="icon-pencil icon-white"></i>修改</a>
                                                                                <a href="<?php echo U('del',array('glid'=>$v['glid'],'gid'=>$_GET['gid']));?>" class="btn btn-danger"><i class="icon-trash icon-white"></i>删除</a>
                                                                        </td>
                                                                </tr>
                                                        <?php }}?>
                                                        <!-- 如果已添加数目小于可能情况数目，才出现添加货品的输入框 -->
                                                        <tr class="info">
                                                                <td>添加货品</td>

                                                                <?php if(is_array($standname)){?><?php  foreach($standname as $key=>$v){ ?>
                                                                        <td>
                                                                                <select name="combattrid[]" style='width:130px;'>
                                                                                        <option value="0">----请选择----</option>
                                                                                        <?php if(is_array($standval)){?><?php  foreach($standval as $key=>$s){ ?>
                                                                                                <?php if($s['type_attr_taid'] == $v['type_attr_taid']){?>
                                                                                                        <option value="<?php echo $s['gaid'];?>"><?php echo $s['ganame'];?></option>
                                                                                                <?php }?>
                                                                                        <?php }}?>
                                                                                </select>
                                                                        </td>
                                                                <?php }}?>
                                                                <td>
                                                                        <input type="text" name='stock'/>
                                                                </td>
                                                                <td>
                                                                        <input type="text" name='number' value="" />
                                                                </td>
                                                                <td><span style="color:#D6261E;padding-left:10px;font-size:14px;font-weight:700;" class='warning'></span></td>
                                                        </tr>
                                                </table>

                                                <input type="hidden" name='goods_gid' value='<?php echo $_GET['gid'];?>'/>
                                                <input type="submit" value='添加货品' class="btn btn-primary"/>
                                        </form>

                                </div>
                        </div>
                </div>
        </body>
</html>